package view;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.document.AbstractXlsView;

@Component
public class MyExcelView extends AbstractXlsView {
	/**
	 * AbstractJExcelView  jexcel api已经过时
	 * AbstractView  poi Api
	 * 简单定义的显示excel数据内容
	 * 建议先写到本地:在输出,
	 * 测试发现 IO 占用特别大
	 */
	@Override
	protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		response.setHeader("content-disposition", "attachment;filename=我的工作簿.xls");
		Sheet sheet = workbook.createSheet("我的工作簿");
		Row row = sheet.createRow(0);
		Cell cell = row.createCell(0);
		Cell cell2 = row.createCell(1);
		cell.setCellValue("1");
		cell2.setCellValue("2");
	}
}
